\(\int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx\) [125]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F(-2)]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 26, antiderivative size = 83 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {a \text {arctanh}\left (\frac {b \cos (c+d x)-a \sin (c+d x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2} d}-\frac {b}{\left (a^2+b^2\right ) d (a \cos (c+d x)+b \sin (c+d x))} \]

[Out]

-a*arctanh((b*cos(d*x+c)-a*sin(d*x+c))/(a^2+b^2)^(1/2))/(a^2+b^2)^(3/2)/d-b/(a^2+b^2)/d/(a*cos(d*x+c)+b*sin(d*
x+c))

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 83, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.115, Rules used = {3234, 3153, 212} \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {a \text {arctanh}\left (\frac {b \cos (c+d x)-a \sin (c+d x)}{\sqrt {a^2+b^2}}\right )}{d \left (a^2+b^2\right )^{3/2}}-\frac {b}{d \left (a^2+b^2\right ) (a \cos (c+d x)+b \sin (c+d x))} \]

[In]

Int[Cos[c + d*x]/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]

[Out]

-((a*ArcTanh[(b*Cos[c + d*x] - a*Sin[c + d*x])/Sqrt[a^2 + b^2]])/((a^2 + b^2)^(3/2)*d)) - b/((a^2 + b^2)*d*(a*
Cos[c + d*x] + b*Sin[c + d*x]))

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3153

Int[(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Dist[-d^(-1), Subst[Int
[1/(a^2 + b^2 - x^2), x], x, b*Cos[c + d*x] - a*Sin[c + d*x]], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2,
0]

Rule 3234

Int[((A_.) + cos[(d_.) + (e_.)*(x_)]*(B_.))/((a_.) + cos[(d_.) + (e_.)*(x_)]*(b_.) + (c_.)*sin[(d_.) + (e_.)*(
x_)])^2, x_Symbol] :> Simp[(c*B + c*A*Cos[d + e*x] + (a*B - b*A)*Sin[d + e*x])/(e*(a^2 - b^2 - c^2)*(a + b*Cos
[d + e*x] + c*Sin[d + e*x])), x] + Dist[(a*A - b*B)/(a^2 - b^2 - c^2), Int[1/(a + b*Cos[d + e*x] + c*Sin[d + e
*x]), x], x] /; FreeQ[{a, b, c, d, e, A, B}, x] && NeQ[a^2 - b^2 - c^2, 0] && NeQ[a*A - b*B, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {b}{\left (a^2+b^2\right ) d (a \cos (c+d x)+b \sin (c+d x))}+\frac {a \int \frac {1}{a \cos (c+d x)+b \sin (c+d x)} \, dx}{a^2+b^2} \\ & = -\frac {b}{\left (a^2+b^2\right ) d (a \cos (c+d x)+b \sin (c+d x))}-\frac {a \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,b \cos (c+d x)-a \sin (c+d x)\right )}{\left (a^2+b^2\right ) d} \\ & = -\frac {a \text {arctanh}\left (\frac {b \cos (c+d x)-a \sin (c+d x)}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2} d}-\frac {b}{\left (a^2+b^2\right ) d (a \cos (c+d x)+b \sin (c+d x))} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.52 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.95 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\frac {\frac {2 a \text {arctanh}\left (\frac {-b+a \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2}}-\frac {b}{\left (a^2+b^2\right ) (a \cos (c+d x)+b \sin (c+d x))}}{d} \]

[In]

Integrate[Cos[c + d*x]/(a*Cos[c + d*x] + b*Sin[c + d*x])^2,x]

[Out]

((2*a*ArcTanh[(-b + a*Tan[(c + d*x)/2])/Sqrt[a^2 + b^2]])/(a^2 + b^2)^(3/2) - b/((a^2 + b^2)*(a*Cos[c + d*x] +
 b*Sin[c + d*x])))/d

Maple [A] (verified)

Time = 0.53 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.42

method result size
derivativedivides \(\frac {-\frac {2 \left (-\frac {b^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}+b^{2}\right ) a}-\frac {b}{a^{2}+b^{2}}\right )}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a}+\frac {2 a \,\operatorname {arctanh}\left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}}{d}\) \(118\)
default \(\frac {-\frac {2 \left (-\frac {b^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\left (a^{2}+b^{2}\right ) a}-\frac {b}{a^{2}+b^{2}}\right )}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2} a -2 b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-a}+\frac {2 a \,\operatorname {arctanh}\left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}}{d}\) \(118\)
risch \(-\frac {2 i b \,{\mathrm e}^{i \left (d x +c \right )}}{\left (-i a +b \right ) d \left (i a +b \right ) \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right )}+\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}} d}-\frac {a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}} d}\) \(190\)

[In]

int(cos(d*x+c)/(cos(d*x+c)*a+b*sin(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(-2*(-b^2/(a^2+b^2)/a*tan(1/2*d*x+1/2*c)-b/(a^2+b^2))/(tan(1/2*d*x+1/2*c)^2*a-2*b*tan(1/2*d*x+1/2*c)-a)+2*
a/(a^2+b^2)^(3/2)*arctanh(1/2*(2*a*tan(1/2*d*x+1/2*c)-2*b)/(a^2+b^2)^(1/2)))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 215 vs. \(2 (79) = 158\).

Time = 0.26 (sec) , antiderivative size = 215, normalized size of antiderivative = 2.59 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {2 \, a^{2} b + 2 \, b^{3} - {\left (a^{2} \cos \left (d x + c\right ) + a b \sin \left (d x + c\right )\right )} \sqrt {a^{2} + b^{2}} \log \left (-\frac {2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) - a \sin \left (d x + c\right )\right )}}{2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}}\right )}{2 \, {\left ({\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} d \cos \left (d x + c\right ) + {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} d \sin \left (d x + c\right )\right )}} \]

[In]

integrate(cos(d*x+c)/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(2*a^2*b + 2*b^3 - (a^2*cos(d*x + c) + a*b*sin(d*x + c))*sqrt(a^2 + b^2)*log(-(2*a*b*cos(d*x + c)*sin(d*x
 + c) + (a^2 - b^2)*cos(d*x + c)^2 - 2*a^2 - b^2 + 2*sqrt(a^2 + b^2)*(b*cos(d*x + c) - a*sin(d*x + c)))/(2*a*b
*cos(d*x + c)*sin(d*x + c) + (a^2 - b^2)*cos(d*x + c)^2 + b^2)))/((a^5 + 2*a^3*b^2 + a*b^4)*d*cos(d*x + c) + (
a^4*b + 2*a^2*b^3 + b^5)*d*sin(d*x + c))

Sympy [F(-2)]

Exception generated. \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=\text {Exception raised: AttributeError} \]

[In]

integrate(cos(d*x+c)/(a*cos(d*x+c)+b*sin(d*x+c))**2,x)

[Out]

Exception raised: AttributeError >> 'NoneType' object has no attribute 'primitive'

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 182 vs. \(2 (79) = 158\).

Time = 0.31 (sec) , antiderivative size = 182, normalized size of antiderivative = 2.19 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {a \log \left (\frac {b - \frac {a \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \sqrt {a^{2} + b^{2}}}{b - \frac {a \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} + \frac {2 \, {\left (a b + \frac {b^{2} \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1}\right )}}{a^{4} + a^{2} b^{2} + \frac {2 \, {\left (a^{3} b + a b^{3}\right )} \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - \frac {{\left (a^{4} + a^{2} b^{2}\right )} \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}}}{d} \]

[In]

integrate(cos(d*x+c)/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="maxima")

[Out]

-(a*log((b - a*sin(d*x + c)/(cos(d*x + c) + 1) + sqrt(a^2 + b^2))/(b - a*sin(d*x + c)/(cos(d*x + c) + 1) - sqr
t(a^2 + b^2)))/(a^2 + b^2)^(3/2) + 2*(a*b + b^2*sin(d*x + c)/(cos(d*x + c) + 1))/(a^4 + a^2*b^2 + 2*(a^3*b + a
*b^3)*sin(d*x + c)/(cos(d*x + c) + 1) - (a^4 + a^2*b^2)*sin(d*x + c)^2/(cos(d*x + c) + 1)^2))/d

Giac [A] (verification not implemented)

none

Time = 0.33 (sec) , antiderivative size = 138, normalized size of antiderivative = 1.66 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {a \log \left (\frac {{\left | 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, b - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, b + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + a b\right )}}{{\left (a^{3} + a b^{2}\right )} {\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 2 \, b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - a\right )}}}{d} \]

[In]

integrate(cos(d*x+c)/(a*cos(d*x+c)+b*sin(d*x+c))^2,x, algorithm="giac")

[Out]

-(a*log(abs(2*a*tan(1/2*d*x + 1/2*c) - 2*b - 2*sqrt(a^2 + b^2))/abs(2*a*tan(1/2*d*x + 1/2*c) - 2*b + 2*sqrt(a^
2 + b^2)))/(a^2 + b^2)^(3/2) - 2*(b^2*tan(1/2*d*x + 1/2*c) + a*b)/((a^3 + a*b^2)*(a*tan(1/2*d*x + 1/2*c)^2 - 2
*b*tan(1/2*d*x + 1/2*c) - a)))/d

Mupad [B] (verification not implemented)

Time = 22.66 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.64 \[ \int \frac {\cos (c+d x)}{(a \cos (c+d x)+b \sin (c+d x))^2} \, dx=-\frac {\frac {2\,b}{a^2+b^2}+\frac {2\,b^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{a\,\left (a^2+b^2\right )}}{d\,\left (-a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+2\,b\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+a\right )}+\frac {a\,\mathrm {atan}\left (\frac {a^2\,b\,1{}\mathrm {i}+b^3\,1{}\mathrm {i}-a\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a^2+b^2\right )\,1{}\mathrm {i}}{{\left (a^2+b^2\right )}^{3/2}}\right )\,2{}\mathrm {i}}{d\,{\left (a^2+b^2\right )}^{3/2}} \]

[In]

int(cos(c + d*x)/(a*cos(c + d*x) + b*sin(c + d*x))^2,x)

[Out]

(a*atan((a^2*b*1i + b^3*1i - a*tan(c/2 + (d*x)/2)*(a^2 + b^2)*1i)/(a^2 + b^2)^(3/2))*2i)/(d*(a^2 + b^2)^(3/2))
 - ((2*b)/(a^2 + b^2) + (2*b^2*tan(c/2 + (d*x)/2))/(a*(a^2 + b^2)))/(d*(a + 2*b*tan(c/2 + (d*x)/2) - a*tan(c/2
 + (d*x)/2)^2))